package com.wulis.seckill.enums;

/**
 * 秒杀库存枚举
 */
public enum SecKillInventoryEnum {
    //already SEC KILL
    SEC_KILL_SUCCESS("200", "秒杀库存成功"),
    ALREADY_SEC_KILL_SUCCESS("300", "已经秒杀库存成功"),
    INVENTORY_SHORTAGE("400", "库存不足"),
    NOT_EXIST("600", "库存不存在"),
    SEC_KILL_ERROR("700", "秒杀库存失败");
    private String code;
    private String desc;

    SecKillInventoryEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public String code() {
        return this.code;
    }

    public String desc() {
        return this.desc;
    }

    public static SecKillInventoryEnum getSecKillSuccess(String code) {
        for (SecKillInventoryEnum secKillInventoryEnum : SecKillInventoryEnum.values()) {
            if (secKillInventoryEnum.code().equals(code)) {
                return secKillInventoryEnum;
            }
        }
        return null;
    }
}
